//
//  ShortMessageCell.m
//  phmall
//
//  Created by admin on 2017/12/19.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "ShortMessageCell.h"

@implementation ShortMessageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)theShareCellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"SetCell";
    ShortMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[ShortMessageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.headImage=[[UIImageView alloc]init];
        self.headImage.image=[UIImage imageNamed:@"头像"];
        ViewBorderRadius(self.headImage, 3, 0.5, [UIColor groupTableViewBackgroundColor]);
        [self.contentView addSubview:self.headImage];
//
        self.name=[[UILabel alloc]init];
        self.name.text=@"收件人阿萨德";
        self.name.font=[UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.name];

        self.time=[[UILabel alloc]init];
        self.time.text=@"2017/10/29 09:04:25";
        self.time.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.time.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.time];
        
        self.title=[[UILabel alloc]init];
        self.title.text=@"标题标题标题标题标题标题标题标题";
        self.title.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.title.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.title];
        
        self.line=[UIView new];
        self.line.backgroundColor=[UIColor groupTableViewBackgroundColor];
        [self.contentView  addSubview:self.line];
        
        UIImageView *leave=[[UIImageView alloc]init];
        leave.image=[UIImage imageNamed:@"前往"];
        [self.contentView addSubview:leave];
        [leave mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.width.height.offset(15);
            make.right.offset(-10);
        }];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    
    [self.headImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.centerY.offset(0);
        make.width.height.offset(60);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headImage.mas_right).offset(10);
        make.top.offset(15);
    }];
    
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headImage.mas_right).offset(10);
        make.bottom.offset(-15);
    }];
    
    [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-35);
        make.top.offset(15);
    }];

    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.left.right.offset(0);
        make.height.mas_equalTo(1);
    }];
}
-(void)setModel:(MessageModel *)model{
    _model=model;
    NSLog(@"%@",model.img);
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@union/%@",IMGURL,model.img]] placeholderImage:[UIImage imageNamed:@"图片空白页"]];
    
    self.name.text=model.to_id;
    self.title.text=[NSString stringWithFormat:@"%@",model.title];;
    self.time.text=[NSString stringWithFormat:@"%@",model.reg_date];

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
